package com.scrx.ymg.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public final class BaseUtil {
	
	
	public final static String goodsPath="E:\\ProjectImage\\JBT\\main\\";
	public final static String hotsPath = "E:\\ProjectImage\\JBT\\main\\";
	public final static String supersPath = "E:\\ProjectImage\\JBT\\main\\";
	public final static String othersPath = "E:\\ProjectImage\\JBT\\main\\";
	public final static String seckillsPath = "E:\\ProjectImage\\JBT\\main\\";
	public static String ProductPath = "";
	public static String QRCode = "";
	
	
	
	public static Map<String, String> sessionKey=new HashMap<String, String>();

	/**
	 * 图片前面加上随机数字和字母
	 * @param imgName
	 * @return
	 */
	public static String addRandom(String imgName){
		String str = "";  
	    Random random = new Random();  
	    for (int i = 0; i < 6; i++) {
	        boolean b = random.nextBoolean();  
	        if (b) { // 字符串  1
	            // int choice = random.nextBoolean() ? 65 : 97; 取得65大写字母还是97小写字母  
	            str += (char) (65 + random.nextInt(26));// 取得大写字母  
	        } else { // 数字  
	            str += String.valueOf(random.nextInt(10));  
	        }  
	    }
		return str+imgName;
	}
	
	 public static String newdate(){
	    	SimpleDateFormat  formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
	    	return formatter.format(new Date());
	    }
	
    
	public static String getJsonString(String Jsonstr,String str){
		Gson gson = new Gson();
		Map<String, String> retMap = gson.fromJson(Jsonstr,    
			    new TypeToken<Map<String, String>>(){}.getType());
		return retMap.get(str);
	}
	
	
	
}
